﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;

namespace entgpguayas
{
    public class Global : System.Web.HttpApplication
    {

        protected void Application_Start(object sender, EventArgs e)
        {

        }

        protected void Session_Start(object sender, EventArgs e)
        {

        }

        protected void Application_BeginRequest(object sender, EventArgs e)
        {
            // Original fix credit to Stefan Mohr
            // Bug fix for MS SSRS Blank.gif 500 server error missing parameter IterationId
            // https://connect.microsoft.com/VisualStudio/feedback/details/556989/
            //<img src="/gpguayas/Reserved.ReportViewerWebControl.axd?Culture=12298&amp;CultureOverrides=True&amp;UICulture=3082&amp;UICultureOverrides=True&amp;ReportStack=1&amp;ControlID=604c1c7f03f4499ab8c0068b75c37a31&amp;Mode=true&amp;OpType=ReportImage&amp;ResourceStreamID=Blank.gif">
            if (HttpContext.Current.Request.Url.PathAndQuery.Contains("/Reserved.ReportViewerWebControl.axd") &&
                !HttpContext.Current.Request.Url.ToString().ToLower().Contains("iteration") &&
                !String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["ResourceStreamID"]) &&
                HttpContext.Current.Request.QueryString["ResourceStreamID"].ToLower().Equals("blank.gif"))
            {
                Context.RewritePath(String.Concat(HttpContext.Current.Request.Url.PathAndQuery, "&IterationId=0"));
            }
        }

        protected void Application_AuthenticateRequest(object sender, EventArgs e)
        {

        }

        protected void Application_Error(object sender, EventArgs e)
        {

        }

        protected void Session_End(object sender, EventArgs e)
        {

        }

        protected void Application_End(object sender, EventArgs e)
        {

        }
    }
}